<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<!-- <link rel="shortcut icon" href="img/logo.ico" /> -->
		<title>合作方申请记录</title>
    <link href="plugin/date/date.css" rel="stylesheet">
		<link href="bootstrap/css/bootstrap3.min.css" rel="stylesheet">
    <link href="//netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
		<link rel="stylesheet" href="css/nav.css" />
  </head>
  <body>
	  <!--导航-->
      <nav class="navbar navbar-inverse">
        <div class="container-fluid">
          <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-2">
              <span class="sr-only">Toggle navigation</span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
            </button>
  	          	<a class="navbar-brand" href=""><img src="images/admin_logo.png" alt=""></a>
          </div>

          <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-2">
            <ul class="nav navbar-nav" id="nav">

            </ul>
            <ul class="nav navbar-nav navbar-right">
              <li class="dropdown">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">欢迎您：<span id="uname"></span><span class="caret"></span></a>
                <ul class="dropdown-menu" role="menu">
                  <li><a href="change_pass.html">修改密码</a></li>
                  <li><a id="loginOut" href="#">退出登陆</a></li>
                </ul>
              </li>
            </ul>
          </div>
        </div>
      </nav>
    <div class="container-fluid">
			<div class="row bcert-box">
        <ol class="breadcrumb">
          <li><a href="javascript:;">主页</a></li>
          <li>会员管理</li>
          <li class="active">合作方申请记录</li>
        </ol>

        <form class="form-inline searchForm" id="">
          <div class="form-group">
            <span class="theme-title">处理状态:</span>
            <select class="form-control drop-down" name='operationType' id="status">
			  <option value="0">未处理</option>
              <option value="1">已处理</option>
			  <option value="">全部</option>

            </select>
          </div>
          <div class="form-group">
              <input type="text" class="form-control" style="padding-left:12px;" name="userId" id="member_name" placeholder="姓名">
          </div>
          <div class="form-group">
              <input type="text" class="form-control" style="padding-left:12px;" name="orderNo" id="phone" placeholder="手机号">
          </div>
          <!-- <div class="form-group">
              <input type="text" class="form-control" style="padding-left:12px;" name="cbkMobile" id="cbkMobile" placeholder="转入人cbk手机号">
          </div> -->
          <div class="form-group">
              <input type="text" class="form-control" style="padding-left:12px;" name="startTime" title="错误"
               readonly="readonly"
               data-container="body"
               data-toggle="popover"
               data-placement="bottom"
               data-content="开始时间不能大于结束时间!"
               id="startTime" placeholder="开始时间">
          </div>
          <div class="form-group">
              <input type="text" class="form-control" style="padding-left:12px;" readonly="readonly" name="endTime" id="endTime" placeholder="结束时间">
          </div>
          <div class="form-group">
            <button type="button" class="btn btn-primary btn-success" id="Reset"></span>重置</button>
            <button type="button" class="btn btn-primary btn-default" id="QueryBtn" data-toggle="button" aria-pressed="false" autocomplete="off">查询</button>
            <!-- <button type="button" class="btn btn-primary btn-success" id="dlexcle"></span>&nbsp;导出excle</button> -->
          </div>
        </form>
        <div class="table">
          <table class="table table-bordered table-striped" id="integralList">

          </table>
        </div>
      </div>
      <!-- 分页 -->
        <nav aria-label="...">
          <div class="">
            <span id="pageNum">共&nbsp;<strong></strong>&nbsp;页&nbsp;/&nbsp;</span><span id="totalNum">&nbsp;<strong>0</strong>&nbsp;条数据</span>
          </div>
          <ul id="example"></ul>
        </nav>
    </div>
  </body>
  <script src="js/jquery.min.js"></script>
  <script type="text/javascript" src="plugin/layer/layer.js"></script>
  <script type="text/javascript" src="js/cookie.js"></script>
  <script type="text/javascript" src="js/common.js"></script>
  <script type="text/javascript" src="js/ajax.js"></script>
  <script type="text/javascript" src="bootstrap/js/bootstrap.min.js" ></script>
  <script type="text/javascript" src="js/bootstrap-paginator.js"></script>
  <script type="text/javascript" src="plugin/date/date.js"></script>
  <script type="text/javascript" src="plugin/date/date.zh-CN.js"></script>
  <script>

  $("document").ready(function(){
    tableList()
    // inputEmpty()
  })

  //分页
  var pageUrls =  serverURL + '/platform/queryMemberAgency';
  function tableList(){
    data = {
		'name':$('#member_name').val(),
		'mobile':$('#phone').val(),
		'status':$('#status').val(),
		'startTime':$('#startTime').val(),
		'endTime':$('#endTime').val(),
		'page': page,
		'pageSize': pagesize
      }
	  data.page = 1
	  ajax(
		  pageUrls,
		  data,
		  pageNumList,
		  'post',
		  'json'
	  )
  }

  //数据渲染
  function OpendList(reg){
    var result = '';
    $('#integralList').empty();
    $('#integralList').append(
      '<tr>' +
	  '<th>记录id</th>' +
	  '<th>会员id</th>' +
      '<th>手机</th>' +
      '<th>姓名</th>' +
      '<th> 申请时间</th>' +
      '<th>处理状态</th>' +
      '<th class="text-center">操作</th>' +
      '</tr>'
    );
    for (var i = 0; i < reg.data.list.length; i++) {
        var time = getMyDate(reg.data.list[i].createTime);
		 var status = ''
		 if (reg.data.list[i].status == 1) {
			status = '已处理'
		}else if (reg.data.list[i].status == 0) {
			status = '未处理'
		}
        result +=
               '<tr>'+
			   	'<td>'+ reg.data.list[i].agencyId +'</td>'+
                 '<td>'+ reg.data.list[i].memberId +'</td>'+
                 '<td>'+ reg.data.list[i].memberMobile +'</td>'+
                 '<td>'+ reg.data.list[i].memberName +'</td>'+
                 '<td>'+ reg.data.list[i].addTime +'</td>'+
                 '<td>'+ status +'</td>'+
                 '<td class="text-center integral_operation">'
					if (reg.data.list[i].status == 0) {
						result +='<button data-id="'+ reg.data.list[i].agencyId +'"  class="btn btn-primary btn-sm recommend" data-toggle="modal" data-target=".bs-example-modal-sm">处理</button>'
					}else if (reg.data.list[i].status == 1) {
						result += '无'
					}
 				result +='</td>'+
               '</tr>'
    }
    $('#integralList').append(result)

  }
  //查询
  $('#QueryBtn').click(function(){
    tableList()
  })

  function compareDate(startTime, endTime) {
         return new Date(startTime).getTime() > new Date(endTime).getTime();
     }

     function checkStartAndEndTime() {
         if(compareDate($('#startTime').val(), $('#endTime').val())){
             $('#startTime').addClass("card-warning");
             $('#startTime').popover('show');

         }else{
             $('#startTime').removeClass("card-warning");
             $('#startTime').popover('hide')
         }
     }

     //时间选择
     $("#startTime").datetimepicker({
         format: "yyyy-mm-dd",
         autoclose: true,
         todayBtn: true,
         todayHighlight: true,
        //  endTime:new Date(),
         showMeridian: true,
         pickerPosition: "bottom-left",
         language: 'zh-CN',//中文，需要引用zh-CN.js包
         startView: 2,//月视图
         minView: 2,//日期时间选择器所能够提供的最精确的时间选择视图
     }).change(function () {
         checkStartAndEndTime();
     });
     $("#endTime").datetimepicker({
         format: "yyyy-mm-dd",
         autoclose: true,
         todayBtn: true,
         todayHighlight: true,
        //  endTime:new Date(),
         showMeridian: true,
         pickerPosition: "bottom-left",
         language: 'zh-CN',//中文，需要引用zh-CN.js包
         startView: 2,//月视图
         minView: 2,//日期时间选择器所能够提供的最精确的时间选择视图
     }).change(function () {
         checkStartAndEndTime();
     });

	 //处理
 	$(document).on('click', '.recommend', function() {
 	  	var id = $(this).attr('data-id')
 	  	layer.confirm('确定已处理申请记录？', {
 	     	btn: ['确定','取消'] //按钮
 	    }, function(){
 	    	deleteList (id)
 	    }, function(){
 	    });
 	})
	//处理
	function deleteList (id){
		var data = {
			'id':id,
		}
		var callback = function(res){
			tableList();
		}
		ajax(
			serverURL + '/platform/checkMemberAgency',
			data,
			callback,
			'post',
			'json'
		)
		$.ajax({
			url: serverURL +  '/member/handleRealDataAgency',
			type: "post",
			dataType: "json",
			data: {
			  'ids':id,
			},
			success: function (data) {
				console.log(data.msg)
				layer.msg(data.msg)
				if (data.code == 400) {
					alert("登陆超时请重新登陆")
					window.location.href = "login.html";
				}else if (data.code == 200) {
					tableList();
				}
			}
		});
	}
  </script>
</html>
